home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1833 / 1833.xpi / components / app-startup-observer.js next >
Text File  |  2009-12-16  |  2KB  |  71 lines

  1. const SERVICE_NAME="Yoono Observer";
  2. const SERVICE_CID = Components.ID("{29ecb220-c802-11dc-95ff-0800200c9a66}");
  3. const SERVICE_CTRID = "@yoono.com/yoono-connect;1";
  4.  
  5. const CI = Components.interfaces;
  6. const CL = Components.classes;
  7.  
  8. var Observer = {
  9.   observe: function(aSubject, aTopic, aData) {
  10.     if (aTopic!="app-startup") return;
  11.     
  12.     // Just notify main module of application startup
  13.     Components.utils.import("resource://yoono/yoonoService.js");
  14.     YOONO_CMPT.observe(aSubject, aTopic, aData);
  15.     
  16.   },
  17.   QueryInterface : function (iid) {
  18.     if(!iid.equals(CI.nsISupports) && !iid.equals(CI.nsIObserver))
  19.       throw Components.results.NS_ERROR_NO_INTERFACE;
  20.     return this;
  21.   }
  22. };
  23.  
  24. // routine de declaration  du composant
  25. var Module = {
  26.   registerSelf : function (compMgr, fileSpec, location, type) {
  27.     // enregistrement
  28.     compMgr.QueryInterface(CI.nsIComponentRegistrar).
  29.       registerFactoryLocation(SERVICE_CID, SERVICE_NAME, SERVICE_CTRID, fileSpec, location, type);
  30.     // definition des categories
  31.     var catman = CL['@mozilla.org/categorymanager;1'].getService(CI.nsICategoryManager);
  32.     catman.addCategoryEntry("app-startup", SERVICE_NAME, "service,"+SERVICE_CTRID, true, true);
  33.   },
  34.  
  35.   unregisterSelf : function(compMgr, fileSpec, location) {
  36.     // suppression categories
  37.     var catman = CL['@mozilla.org/categorymanager;1'].getService(CI.nsICategoryManager);
  38.     catman.deleteCategoryEntry("app-startup", SERVICE_NAME, true);
  39.     // desenregistrement
  40.     compMgr.QueryInterface(CI.nsIComponentRegistrar)
  41.       .unregisterFactoryLocation(SERVICE_CID, fileSpec);
  42.  
  43.   },
  44.  
  45.   getClassObject : function (compMgr, cid, iid) {
  46.     if(cid.equals(SERVICE_CID)) {
  47.       return  {  // nsIFactory
  48.         createInstance: function (outer, iid) {
  49.           if (outer != null) throw Components.results.NS_ERROR_NO_AGGREGATION;
  50.             return Observer;
  51.         }
  52.       };
  53.     }
  54.  
  55.     if (!iid.equals(CI.nsIFactory))
  56.       throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  57.  
  58.     throw Components.results.NS_ERROR_NO_INTERFACE;
  59.   },
  60.  
  61.  
  62.   canUnload : function(compMgr) {
  63.     return true;
  64.   }
  65.  
  66. };
  67.  
  68. function NSGetModule(compMgr, fileSpec) {
  69.   return Module;
  70. }
  71.